from PyQt5.Qt import *


class MyBtn(QPushButton):
    rightClicked = pyqtSignal()
    # 信号重载
    # 测试发现信号中不能有下划线
    signalWithParam = pyqtSignal([str])
    signalWithParam = pyqtSignal([str], [int, str])
    # error !!
    # signal_with_param = pyqtSignal([str])
    # signal_with_param = pyqtSignal([str], [int, str])

    def mousePressEvent(self, evt):
        super().mousePressEvent(evt)
        # how to get 鼠标滚轮事件
        #print(evt.button())
        if evt.button() == Qt.RightButton:
            self.rightClicked.emit()
        elif evt.button() == Qt.MidButton:
            #self.signal_with_param[str].emit('mid button is pressed')
            #self.signal_with_param[int, str].emit(1, 'mid button is pressed')
            self.signalWithParam[str].emit('mid button is pressed')


if __name__ == '__main__':
    import sys
    app = QApplication(sys.argv)

    win = QWidget()
    btn = MyBtn('测试按钮', win)

    win.show()

    sys.exit(app.exec_())
